﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using System.IO;

namespace B2BAktarim
{
    static class Program
    {
        public static DevExpress.LookAndFeel.DefaultLookAndFeel look = new DevExpress.LookAndFeel.DefaultLookAndFeel();

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Database db = Database.LoadDb;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Settings.Instance.Path = Application.StartupPath;

            look.LookAndFeel.SkinName = "Black";
            DevExpress.Skins.SkinManager.EnableFormSkins();

            bool acik;
            Mutex Mtx = new Mutex(true, "B2BAktarim", out acik);
            if (!acik)
            {
                MessageBox.Show("Bu program, zaten Çalışıyor.");
                return;
            }
            GC.KeepAlive(Mtx);

            if (!File.Exists(string.Format("{0}\\B2B.ini", Application.StartupPath)))
            {
                frmAyar ayar = new frmAyar();
                ayar.ShowDialog();
            }
            else
                Settings.Instance.Open();

            Application.Run(new frmMain());

            Settings.Instance.Close();
            db.SaveDb();
        }
    }
}
